#define _CRT_SECURE_NO_WARNINGS 1
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: user
 * Date: 2023-11-01
 * Time: 17:22
 */

        #include <string.h>

        int main() {
        int n, m;
        scanf("%d %d", &n, &m);
        int arr1[1000] = { 0 };
        int arr2[1000] = { 0 };

        for (int i = 0; i < n; i++)
        {
        scanf("%d", &arr1[i]);
        }

        for (int j = 0; j < m; j++)
        {
        scanf("%d", &arr2[j]);
        }

        //以上代码 将数据全部存储好了
        int i = 0;
        int j = 0;
        while (i < n && j < m)
        {
        //两个数组都有元素
        if (arr1[i] < arr2[j])
        {
        printf("%d ", arr1[i]);
        i++;
        }
        else
        {
        printf("%d ", arr2[j]);
        j++;
        }
        }
        //剩下的元素 全部都打印
        while (i < n)
        {
        printf("%d ", arr1[i]);
        i++;
        }

        //剩下的元素 全部都打印
        while (j < m)
        {
        printf("%d ", arr2[j]);
        j++;
        }
        return 0;
        }
        int main13()
        {
        int arr1[5] = { 1,2,3,4,5 };
        int arr2[5] = { 11,21,31,41,51 };

        for (int i = 0; i < 5; i++)
        {
        int tmp = arr1[i];
        arr1[i] = arr2[i];
        arr2[i] = tmp;
        }
        for (int i = 0; i < 5; i++)
        {
        printf("%d ",arr1[i]);
        }
        printf("\n");
        for (int i = 0; i < 5; i++)
        {
        printf("%d ", arr2[i]);
        }
        return 0;
        }
        int main12() {

        int arr[10] = { 0 };
        for (int i = 0; i < 10; i++)
        {
        scanf("%d", &arr[i]);
        }

        for (int i = 9; i >= 0; i--)
        {
        printf("%d ", arr[i]);
        }
        return 0;
        }
//int main() {
//    int a, b;
//    while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case
//        // 64 位输出请用 printf("%lld") to
//        int arr[a][b];
//        for (int i = 0; i < a; i++)
//        {
//            for (int j = 0; j < b; j++)
//            {
//                scanf("%d", &arr[i][j]);
//            }
//        }
//
//        //转置  2 3  -> 3  2
//        for (int i = 0; i < b; i++)
//        {
//            for (int j = 0; j < a; j++)
//            {
//                printf("%d ", arr[j][i]);
//            }
//            printf("\n");
//        }
//    }
//    return 0;
//}
        int main11() {
        int n;
        while (scanf("%d", &n) != EOF) { // 注意 while 处理多个 case
        // 64 位输出请用 printf("%lld") to

        for (int i = 0; i < n; i++)
        {
        for (int j = 0; j < n; j++)
        {
        if (i == 0 || i == n - 1)
        {
        //第一行 和 最后一行
        printf("* ");
        }
        else if (j == 0 || j == n - 1)
        {
        printf("* ");
        }
        else
        {
        printf("  ");
        }
        }
        printf("\n");
        }
        }
        return 0;
        }
        int main10() {
        int n;
        while (scanf("%d", &n) != EOF) { // 注意 while 处理多个 case
        // 64 位输出请用 printf("%lld") to
        for (int i = 0; i < n; i++)
        {
        for (int j = 0; j < n; j++)
        {
        if (i == j || (i + j) == n - 1)
        {
        printf("*");
        }
        else
        {
        printf(" ");
        }
        }
        printf("\n");
        }
        }
        return 0;
        }
        int main9()
        {
        int arr[10] = { 0 };
        int sum = 0;
        for (int i = 0;i < 10;i++)
        {
        scanf("%d", &arr[i]);
        sum += arr[i];
        }

        //
        //for (int i = 0; i < 10; i++)
        //{
        //   sum += arr[i];
        //}
        double avg = sum / 10.0;
        printf("avg = %lf\n", avg);
        return 0;
        }
        int main8()
        {
        char str[] = "hello bit";

        printf("%d %d\n", sizeof(str), strlen(str));
        return 0;
        }

        int main7()
        {
        int arr[] = { 1,2,9,5 };
        printf("%d\n", arr);
        printf("%d\n", &arr[0]);



        //int a = 24;//18
        //int b = 18;//24???

        //int c = a % b;//6
        //while (c != 0)
        //{
        //    a = b;//18
        //    b = c;//6
        //    c = a % b;//0
        //}
        //printf("%d\n",b);
        return 0;
        }
        int main6()
        {
        int count = 0;
        for (int i = 1; i <= 100; i++)
        {
        if (i % 10 == 9)
        {
        count++;
        }
        else if (i / 10 == 9)
        {
        count++;
        }
        }
        printf("%d\n",count);
        return 0;
        }
        int main5()
        {
        double sum = 0;
        int flg = 1;
        for (int i = 1; i <= 100; i++)
        {
        sum += 1.0 / i * flg;
        flg = -flg;
        }
        printf("sum = %lf\n", sum);
        return 0;
        }

        int main4()
        {
        int arr[10] = {0};
        for (int i = 0; i < 10; i++)
        {
        scanf("%d",&arr[i]);
        }
        //开始找最大值
        //12   3   16   6
        int max = arr[0];
        for (int i = 1; i < 10; i++)
        {
        if (arr[i] > max) {
        max = arr[i];
        }
        }
        printf("max = %d\n",max);
        return 0;
        }
        int main3()
        {
        for (int i = 1; i <= 9; i++)
        {
        for (int j = 1; j <= i; j++)
        {
        printf("%d * %d = %2d ", j, i,i*j);
        }
        printf("\n");
        }
        return 0;
        }

        int main2() {
        int a, b, c;
        while (scanf("%d %d %d", &a, &b, &c) != EOF) { // 注意 while 处理多个 case
        // 64 位输出请用 printf("%lld") to
        if ((a + b) > c && (a + c) > b && (b + c) > a) {
        if (a == b && b == c) {
        //等边三角形
        printf("Equilateral triangle!\n");
        }
        else if ((a == b) && (b != c) || (a == c) && (c != b) || (b == c) && (c != a)) {//等腰三角形
        printf("Isosceles triangle!\n");
        }
        else {
        printf("Ordinary triangle!\n");
        }
        }
        else {
        printf("Not a triangle!\n");
        }
        }
        return 0;
        }
        int main1()
        {
        //"abcdef"
        char* str1 = "abcdef";
        char* str2 = "abcfef";
        int ret = strcmp(str1, str2);
        printf("%d\n",ret);



	/*char str3[] = "abcdef";
	char str4[] = "abcdef";*/

        //str3存储了字符a的地址

        return 0;
        }
